package org.cadoc;

import java.io.File;

import org.cadoc.cqe.CQE;
import org.cadoc.cqe.CodeQueryEngine;
import org.cadoc.cqe.PatternContext;
import org.cadoc.cqe.logic.ModifierVariable;
import org.cadoc.cqe.logic.OperationVariable;
import org.cadoc.cqe.logic.Pattern;
import org.cadoc.cqe.logic.PatternQuery;
import org.cadoc.cqe.logic.TypeVariable;
import org.cadoc.cqe.logic.predicate.DeclaresOperationPredicate;
import org.cadoc.cqe.logic.predicate.ExtendsPredicate;
import org.cadoc.cqe.logic.predicate.ModifierPredicate;
import org.cadoc.parser.FileSystemInput;
import org.cadoc.parser.statement.Modifier;

public class Main {

	public static int stmtCount = 0;
	/**
	 * @param args
	 */
	public static void main(String[] args) {

		long start = System.currentTimeMillis();
		
		// Define a context domain where to look for patterns.
		PatternContext input = new FileSystemInput(new File("/Users/s8705596/workspace/de.tud.inf.st.rubadoc/src/de"));
		CodeQueryEngine cqe = CQE.getQueryEngine(input);
		
		// Build a logical query. Later, there should be a parser for a DSL to specify queries
		TypeVariable tv1 = new TypeVariable("TV1");
		TypeVariable tv2 = new TypeVariable("TV2");
		OperationVariable ov1 = new OperationVariable("OV1");
		ModifierVariable mv1 = new ModifierVariable("MV1");
		mv1.bindTo(Modifier.ABSTRACT);
		
		Pattern p1 = new PatternQuery();
		p1.addPredicate(new ExtendsPredicate(tv1, tv2));
		p1.addPredicate(new ModifierPredicate(tv1, mv1));
		p1.addPredicate(new DeclaresOperationPredicate(tv2,ov1));
		
		// evaluate the Query
		cqe.evaluate(p1);
		
		System.out.println("Elapsed Time: "+(System.currentTimeMillis()-start)+"ms");
	}

}
